<template>
	<view class="">
		<view class="c_coundetails">
			<view class="">
				<view class="" style="font-size: 20px;">
					{{infoCoupon.couponname}}
				</view>
				<view class="">
					{{infoCoupon.timelimit=='0'?'有效期：'+infoCoupon.timedays+'天':'有效期至：'+infoCoupon.timestr}}
					<!-- 到期时间: {{infoCoupon.timestr}} -->
				</view>
			</view>
			<view class="" style="text-align: right;">
				<view class="">
					消费满 ￥{{infoCoupon.enough}}
				</view>
				<view class="" style="font-size: 20px;">
					{{infoCoupon.backstr}} ￥{{infoCoupon.deduct}}
				</view>
			</view>
		</view>
		<view class="c_counpinfo">
			<view class="" @click="instr=!instr">
				使用说明
			</view>
			<rich-text class="c_counpinfo-instructions" v-show="instr" :nodes="infoCoupon.desc"></rich-text>
			<!-- <view class="c_counpinfo-instructions" v-show="instr">
				{{infoCoupon.desc}}
			</view> -->
		</view>
		<view class="c_btn" @tap="add">
			立即领取
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: "",
				info: "",
				infoCoupon:'',
				instr: true
			}
		},
		onLoad(option) {
			var that = this;
			that.id = option.id;
			that.$axios('Detail/main', "POST", 'coupon', {
				id: that.id
			}).then(res => {
				if (res.data.code == 200) {
					that.info = res.data.data
					that.infoCoupon=that.info.coupon
				}
			}, (error) => {

			})
		},
		methods: {
			add() {
				var that = this;
				that.$axios('Detail/pay', "POST", 'coupon', {
					id: that.id
				}).then(res => {
					if (res.data.code == 200) {
						uni.showToast({
							title: '领取成功',
							duration: 2000
						});
					}
				}, (error) => {

				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #eee;
		padding: 20upx;
		box-sizing: border-box;
	}

	.c_coundetails {
		padding: 20upx;
		box-sizing: border-box;
		background: #fe7e00;
		color: #fff;
	}

	.c_counpinfo {
		margin-top: 20upx;
		background: #fff;
		padding: 20upx;
		box-sizing: border-box;
		// display: flex;
		// align-items: center;
		// justify-content: space-between;
	}

	.c_btn {
		position: fixed;
		bottom: 0;
		width: 100%;
		left: 0;
		text-align: center;
		background: #fff;
		height: 40px;
		line-height: 40px;
		background: #fe7e00;
		color: #fff;
	}

	.c_counpinfo-instructions {
		width: 100%;
		margin-top: 20upx;
	}
</style>
